using System; 
using System.Text; 
using System.Data;
using System.Data.SqlClient;
using System.Data.Common;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Configuration; 
using System.Xml; 
using System.Xml.Serialization;
using SubSonic; 
using SubSonic.Utilities;

namespace LMSData
{
	/// <summary>
	/// Strongly-typed collection for the User class.
	/// </summary>
	[Serializable]
	public partial class UserCollection : ActiveList<User, UserCollection> 
	{	   
		public UserCollection() {}

	}

	/// <summary>
	/// This is an ActiveRecord class which wraps the User table.
	/// </summary>
	[Serializable]
	public partial class User : ActiveRecord<User>
	{
		#region .ctors and Default Settings
		
		public User()
		{
		  SetSQLProps();
		  InitSetDefaults();
		  MarkNew();
		}

		
		private void InitSetDefaults() { SetDefaults(); }

		
		public User(bool useDatabaseDefaults)
		{
			SetSQLProps();
			if(useDatabaseDefaults)
				ForceDefaults();
			MarkNew();
		}

		public User(object keyID)
		{
			SetSQLProps();
			InitSetDefaults();
			LoadByKey(keyID);
		}

		 
		public User(string columnName, object columnValue)
		{
			SetSQLProps();
			InitSetDefaults();
			LoadByParam(columnName,columnValue);
		}

		
		protected static void SetSQLProps() { GetTableSchema(); }

		
		#endregion
		
		#region Schema and Query Accessor
		public static Query CreateQuery() { return new Query(Schema); }

		
		public static TableSchema.Table Schema
		{
			get
			{
				if (BaseSchema == null)
					SetSQLProps();
				return BaseSchema;
			}

		}

		
		private static void GetTableSchema() 
		{
			if(!IsSchemaInitialized)
			{
				//Schema declaration
				TableSchema.Table schema = new TableSchema.Table("User", TableType.Table, DataService.GetInstance("LMS"));
				schema.Columns = new TableSchema.TableColumnCollection();
				schema.SchemaName = @"dbo";
				//columns
				
				TableSchema.TableColumn colvarUserID = new TableSchema.TableColumn(schema);
				colvarUserID.ColumnName = "UserID";
				colvarUserID.DataType = DbType.Int32;
				colvarUserID.MaxLength = 0;
				colvarUserID.AutoIncrement = true;
				colvarUserID.IsNullable = false;
				colvarUserID.IsPrimaryKey = true;
				colvarUserID.IsForeignKey = false;
				colvarUserID.IsReadOnly = false;
				colvarUserID.DefaultSetting = @"";
				colvarUserID.ForeignKeyTableName = "";
				schema.Columns.Add(colvarUserID);
				
				TableSchema.TableColumn colvarUsername = new TableSchema.TableColumn(schema);
				colvarUsername.ColumnName = "Username";
				colvarUsername.DataType = DbType.String;
				colvarUsername.MaxLength = 255;
				colvarUsername.AutoIncrement = false;
				colvarUsername.IsNullable = true;
				colvarUsername.IsPrimaryKey = false;
				colvarUsername.IsForeignKey = false;
				colvarUsername.IsReadOnly = false;
				colvarUsername.DefaultSetting = @"";
				colvarUsername.ForeignKeyTableName = "";
				schema.Columns.Add(colvarUsername);
				
				TableSchema.TableColumn colvarEmail = new TableSchema.TableColumn(schema);
				colvarEmail.ColumnName = "Email";
				colvarEmail.DataType = DbType.String;
				colvarEmail.MaxLength = 255;
				colvarEmail.AutoIncrement = false;
				colvarEmail.IsNullable = true;
				colvarEmail.IsPrimaryKey = false;
				colvarEmail.IsForeignKey = false;
				colvarEmail.IsReadOnly = false;
				colvarEmail.DefaultSetting = @"";
				colvarEmail.ForeignKeyTableName = "";
				schema.Columns.Add(colvarEmail);
				
				TableSchema.TableColumn colvarComment = new TableSchema.TableColumn(schema);
				colvarComment.ColumnName = "Comment";
				colvarComment.DataType = DbType.String;
				colvarComment.MaxLength = 4000;
				colvarComment.AutoIncrement = false;
				colvarComment.IsNullable = true;
				colvarComment.IsPrimaryKey = false;
				colvarComment.IsForeignKey = false;
				colvarComment.IsReadOnly = false;
				colvarComment.DefaultSetting = @"";
				colvarComment.ForeignKeyTableName = "";
				schema.Columns.Add(colvarComment);
				
				TableSchema.TableColumn colvarPassword = new TableSchema.TableColumn(schema);
				colvarPassword.ColumnName = "Password";
				colvarPassword.DataType = DbType.String;
				colvarPassword.MaxLength = 255;
				colvarPassword.AutoIncrement = false;
				colvarPassword.IsNullable = true;
				colvarPassword.IsPrimaryKey = false;
				colvarPassword.IsForeignKey = false;
				colvarPassword.IsReadOnly = false;
				colvarPassword.DefaultSetting = @"";
				colvarPassword.ForeignKeyTableName = "";
				schema.Columns.Add(colvarPassword);
				
				TableSchema.TableColumn colvarPasswordQuestion = new TableSchema.TableColumn(schema);
				colvarPasswordQuestion.ColumnName = "PasswordQuestion";
				colvarPasswordQuestion.DataType = DbType.String;
				colvarPasswordQuestion.MaxLength = 255;
				colvarPasswordQuestion.AutoIncrement = false;
				colvarPasswordQuestion.IsNullable = true;
				colvarPasswordQuestion.IsPrimaryKey = false;
				colvarPasswordQuestion.IsForeignKey = false;
				colvarPasswordQuestion.IsReadOnly = false;
				colvarPasswordQuestion.DefaultSetting = @"";
				colvarPasswordQuestion.ForeignKeyTableName = "";
				schema.Columns.Add(colvarPasswordQuestion);
				
				TableSchema.TableColumn colvarPasswordAnswer = new TableSchema.TableColumn(schema);
				colvarPasswordAnswer.ColumnName = "PasswordAnswer";
				colvarPasswordAnswer.DataType = DbType.String;
				colvarPasswordAnswer.MaxLength = 255;
				colvarPasswordAnswer.AutoIncrement = false;
				colvarPasswordAnswer.IsNullable = true;
				colvarPasswordAnswer.IsPrimaryKey = false;
				colvarPasswordAnswer.IsForeignKey = false;
				colvarPasswordAnswer.IsReadOnly = false;
				colvarPasswordAnswer.DefaultSetting = @"";
				colvarPasswordAnswer.ForeignKeyTableName = "";
				schema.Columns.Add(colvarPasswordAnswer);
				
				TableSchema.TableColumn colvarIsApproved = new TableSchema.TableColumn(schema);
				colvarIsApproved.ColumnName = "IsApproved";
				colvarIsApproved.DataType = DbType.Boolean;
				colvarIsApproved.MaxLength = 0;
				colvarIsApproved.AutoIncrement = false;
				colvarIsApproved.IsNullable = true;
				colvarIsApproved.IsPrimaryKey = false;
				colvarIsApproved.IsForeignKey = false;
				colvarIsApproved.IsReadOnly = false;
				colvarIsApproved.DefaultSetting = @"";
				colvarIsApproved.ForeignKeyTableName = "";
				schema.Columns.Add(colvarIsApproved);
				
				TableSchema.TableColumn colvarLastActivityDate = new TableSchema.TableColumn(schema);
				colvarLastActivityDate.ColumnName = "LastActivityDate";
				colvarLastActivityDate.DataType = DbType.DateTime;
				colvarLastActivityDate.MaxLength = 0;
				colvarLastActivityDate.AutoIncrement = false;
				colvarLastActivityDate.IsNullable = true;
				colvarLastActivityDate.IsPrimaryKey = false;
				colvarLastActivityDate.IsForeignKey = false;
				colvarLastActivityDate.IsReadOnly = false;
				colvarLastActivityDate.DefaultSetting = @"";
				colvarLastActivityDate.ForeignKeyTableName = "";
				schema.Columns.Add(colvarLastActivityDate);
				
				TableSchema.TableColumn colvarLastLoginDate = new TableSchema.TableColumn(schema);
				colvarLastLoginDate.ColumnName = "LastLoginDate";
				colvarLastLoginDate.DataType = DbType.DateTime;
				colvarLastLoginDate.MaxLength = 0;
				colvarLastLoginDate.AutoIncrement = false;
				colvarLastLoginDate.IsNullable = true;
				colvarLastLoginDate.IsPrimaryKey = false;
				colvarLastLoginDate.IsForeignKey = false;
				colvarLastLoginDate.IsReadOnly = false;
				colvarLastLoginDate.DefaultSetting = @"";
				colvarLastLoginDate.ForeignKeyTableName = "";
				schema.Columns.Add(colvarLastLoginDate);
				
				TableSchema.TableColumn colvarLastPasswordChangedDate = new TableSchema.TableColumn(schema);
				colvarLastPasswordChangedDate.ColumnName = "LastPasswordChangedDate";
				colvarLastPasswordChangedDate.DataType = DbType.DateTime;
				colvarLastPasswordChangedDate.MaxLength = 0;
				colvarLastPasswordChangedDate.AutoIncrement = false;
				colvarLastPasswordChangedDate.IsNullable = true;
				colvarLastPasswordChangedDate.IsPrimaryKey = false;
				colvarLastPasswordChangedDate.IsForeignKey = false;
				colvarLastPasswordChangedDate.IsReadOnly = false;
				colvarLastPasswordChangedDate.DefaultSetting = @"";
				colvarLastPasswordChangedDate.ForeignKeyTableName = "";
				schema.Columns.Add(colvarLastPasswordChangedDate);
				
				TableSchema.TableColumn colvarCreationDate = new TableSchema.TableColumn(schema);
				colvarCreationDate.ColumnName = "CreationDate";
				colvarCreationDate.DataType = DbType.DateTime;
				colvarCreationDate.MaxLength = 0;
				colvarCreationDate.AutoIncrement = false;
				colvarCreationDate.IsNullable = true;
				colvarCreationDate.IsPrimaryKey = false;
				colvarCreationDate.IsForeignKey = false;
				colvarCreationDate.IsReadOnly = false;
				colvarCreationDate.DefaultSetting = @"";
				colvarCreationDate.ForeignKeyTableName = "";
				schema.Columns.Add(colvarCreationDate);
				
				TableSchema.TableColumn colvarIsOnline = new TableSchema.TableColumn(schema);
				colvarIsOnline.ColumnName = "IsOnline";
				colvarIsOnline.DataType = DbType.Boolean;
				colvarIsOnline.MaxLength = 0;
				colvarIsOnline.AutoIncrement = false;
				colvarIsOnline.IsNullable = true;
				colvarIsOnline.IsPrimaryKey = false;
				colvarIsOnline.IsForeignKey = false;
				colvarIsOnline.IsReadOnly = false;
				colvarIsOnline.DefaultSetting = @"";
				colvarIsOnline.ForeignKeyTableName = "";
				schema.Columns.Add(colvarIsOnline);
				
				TableSchema.TableColumn colvarIsLockedOut = new TableSchema.TableColumn(schema);
				colvarIsLockedOut.ColumnName = "IsLockedOut";
				colvarIsLockedOut.DataType = DbType.Boolean;
				colvarIsLockedOut.MaxLength = 0;
				colvarIsLockedOut.AutoIncrement = false;
				colvarIsLockedOut.IsNullable = true;
				colvarIsLockedOut.IsPrimaryKey = false;
				colvarIsLockedOut.IsForeignKey = false;
				colvarIsLockedOut.IsReadOnly = false;
				colvarIsLockedOut.DefaultSetting = @"";
				colvarIsLockedOut.ForeignKeyTableName = "";
				schema.Columns.Add(colvarIsLockedOut);
				
				TableSchema.TableColumn colvarLastLockedOutDate = new TableSchema.TableColumn(schema);
				colvarLastLockedOutDate.ColumnName = "LastLockedOutDate";
				colvarLastLockedOutDate.DataType = DbType.DateTime;
				colvarLastLockedOutDate.MaxLength = 0;
				colvarLastLockedOutDate.AutoIncrement = false;
				colvarLastLockedOutDate.IsNullable = true;
				colvarLastLockedOutDate.IsPrimaryKey = false;
				colvarLastLockedOutDate.IsForeignKey = false;
				colvarLastLockedOutDate.IsReadOnly = false;
				colvarLastLockedOutDate.DefaultSetting = @"";
				colvarLastLockedOutDate.ForeignKeyTableName = "";
				schema.Columns.Add(colvarLastLockedOutDate);
				
				TableSchema.TableColumn colvarFailedPasswordAttemptCount = new TableSchema.TableColumn(schema);
				colvarFailedPasswordAttemptCount.ColumnName = "FailedPasswordAttemptCount";
				colvarFailedPasswordAttemptCount.DataType = DbType.Int32;
				colvarFailedPasswordAttemptCount.MaxLength = 0;
				colvarFailedPasswordAttemptCount.AutoIncrement = false;
				colvarFailedPasswordAttemptCount.IsNullable = true;
				colvarFailedPasswordAttemptCount.IsPrimaryKey = false;
				colvarFailedPasswordAttemptCount.IsForeignKey = false;
				colvarFailedPasswordAttemptCount.IsReadOnly = false;
				colvarFailedPasswordAttemptCount.DefaultSetting = @"";
				colvarFailedPasswordAttemptCount.ForeignKeyTableName = "";
				schema.Columns.Add(colvarFailedPasswordAttemptCount);
				
				TableSchema.TableColumn colvarFailedPasswordAttemptWindowStart = new TableSchema.TableColumn(schema);
				colvarFailedPasswordAttemptWindowStart.ColumnName = "FailedPasswordAttemptWindowStart";
				colvarFailedPasswordAttemptWindowStart.DataType = DbType.DateTime;
				colvarFailedPasswordAttemptWindowStart.MaxLength = 0;
				colvarFailedPasswordAttemptWindowStart.AutoIncrement = false;
				colvarFailedPasswordAttemptWindowStart.IsNullable = true;
				colvarFailedPasswordAttemptWindowStart.IsPrimaryKey = false;
				colvarFailedPasswordAttemptWindowStart.IsForeignKey = false;
				colvarFailedPasswordAttemptWindowStart.IsReadOnly = false;
				colvarFailedPasswordAttemptWindowStart.DefaultSetting = @"";
				colvarFailedPasswordAttemptWindowStart.ForeignKeyTableName = "";
				schema.Columns.Add(colvarFailedPasswordAttemptWindowStart);
				
				TableSchema.TableColumn colvarFailedPasswordAnswerAttemptCount = new TableSchema.TableColumn(schema);
				colvarFailedPasswordAnswerAttemptCount.ColumnName = "FailedPasswordAnswerAttemptCount";
				colvarFailedPasswordAnswerAttemptCount.DataType = DbType.Int32;
				colvarFailedPasswordAnswerAttemptCount.MaxLength = 0;
				colvarFailedPasswordAnswerAttemptCount.AutoIncrement = false;
				colvarFailedPasswordAnswerAttemptCount.IsNullable = true;
				colvarFailedPasswordAnswerAttemptCount.IsPrimaryKey = false;
				colvarFailedPasswordAnswerAttemptCount.IsForeignKey = false;
				colvarFailedPasswordAnswerAttemptCount.IsReadOnly = false;
				colvarFailedPasswordAnswerAttemptCount.DefaultSetting = @"";
				colvarFailedPasswordAnswerAttemptCount.ForeignKeyTableName = "";
				schema.Columns.Add(colvarFailedPasswordAnswerAttemptCount);
				
				TableSchema.TableColumn colvarFailedPasswordAnswerAttemptWindowStart = new TableSchema.TableColumn(schema);
				colvarFailedPasswordAnswerAttemptWindowStart.ColumnName = "FailedPasswordAnswerAttemptWindowStart";
				colvarFailedPasswordAnswerAttemptWindowStart.DataType = DbType.DateTime;
				colvarFailedPasswordAnswerAttemptWindowStart.MaxLength = 0;
				colvarFailedPasswordAnswerAttemptWindowStart.AutoIncrement = false;
				colvarFailedPasswordAnswerAttemptWindowStart.IsNullable = true;
				colvarFailedPasswordAnswerAttemptWindowStart.IsPrimaryKey = false;
				colvarFailedPasswordAnswerAttemptWindowStart.IsForeignKey = false;
				colvarFailedPasswordAnswerAttemptWindowStart.IsReadOnly = false;
				colvarFailedPasswordAnswerAttemptWindowStart.DefaultSetting = @"";
				colvarFailedPasswordAnswerAttemptWindowStart.ForeignKeyTableName = "";
				schema.Columns.Add(colvarFailedPasswordAnswerAttemptWindowStart);
				
				TableSchema.TableColumn colvarCreatedOn = new TableSchema.TableColumn(schema);
				colvarCreatedOn.ColumnName = "CreatedOn";
				colvarCreatedOn.DataType = DbType.DateTime;
				colvarCreatedOn.MaxLength = 0;
				colvarCreatedOn.AutoIncrement = false;
				colvarCreatedOn.IsNullable = true;
				colvarCreatedOn.IsPrimaryKey = false;
				colvarCreatedOn.IsForeignKey = false;
				colvarCreatedOn.IsReadOnly = false;
				colvarCreatedOn.DefaultSetting = @"";
				colvarCreatedOn.ForeignKeyTableName = "";
				schema.Columns.Add(colvarCreatedOn);
				
				TableSchema.TableColumn colvarCreatedBy = new TableSchema.TableColumn(schema);
				colvarCreatedBy.ColumnName = "CreatedBy";
				colvarCreatedBy.DataType = DbType.String;
				colvarCreatedBy.MaxLength = 50;
				colvarCreatedBy.AutoIncrement = false;
				colvarCreatedBy.IsNullable = true;
				colvarCreatedBy.IsPrimaryKey = false;
				colvarCreatedBy.IsForeignKey = false;
				colvarCreatedBy.IsReadOnly = false;
				colvarCreatedBy.DefaultSetting = @"";
				colvarCreatedBy.ForeignKeyTableName = "";
				schema.Columns.Add(colvarCreatedBy);
				
				TableSchema.TableColumn colvarModifiedOn = new TableSchema.TableColumn(schema);
				colvarModifiedOn.ColumnName = "ModifiedOn";
				colvarModifiedOn.DataType = DbType.DateTime;
				colvarModifiedOn.MaxLength = 0;
				colvarModifiedOn.AutoIncrement = false;
				colvarModifiedOn.IsNullable = true;
				colvarModifiedOn.IsPrimaryKey = false;
				colvarModifiedOn.IsForeignKey = false;
				colvarModifiedOn.IsReadOnly = false;
				colvarModifiedOn.DefaultSetting = @"";
				colvarModifiedOn.ForeignKeyTableName = "";
				schema.Columns.Add(colvarModifiedOn);
				
				TableSchema.TableColumn colvarModifiedBy = new TableSchema.TableColumn(schema);
				colvarModifiedBy.ColumnName = "ModifiedBy";
				colvarModifiedBy.DataType = DbType.String;
				colvarModifiedBy.MaxLength = 50;
				colvarModifiedBy.AutoIncrement = false;
				colvarModifiedBy.IsNullable = true;
				colvarModifiedBy.IsPrimaryKey = false;
				colvarModifiedBy.IsForeignKey = false;
				colvarModifiedBy.IsReadOnly = false;
				colvarModifiedBy.DefaultSetting = @"";
				colvarModifiedBy.ForeignKeyTableName = "";
				schema.Columns.Add(colvarModifiedBy);
				
				TableSchema.TableColumn colvarIsDeleted = new TableSchema.TableColumn(schema);
				colvarIsDeleted.ColumnName = "IsDeleted";
				colvarIsDeleted.DataType = DbType.Boolean;
				colvarIsDeleted.MaxLength = 0;
				colvarIsDeleted.AutoIncrement = false;
				colvarIsDeleted.IsNullable = false;
				colvarIsDeleted.IsPrimaryKey = false;
				colvarIsDeleted.IsForeignKey = false;
				colvarIsDeleted.IsReadOnly = false;
				
						colvarIsDeleted.DefaultSetting = @"((0))";
				colvarIsDeleted.ForeignKeyTableName = "";
				schema.Columns.Add(colvarIsDeleted);
				
				BaseSchema = schema;
				//add this schema to the provider
				//so we can query it later
				DataService.Providers["LMS"].AddSchema("User",schema);
			}

		}

		#endregion
		
		#region Props
		
		  
		[XmlAttribute("UserID")]
		public int UserID 
		{
			get { return GetColumnValue<int>("UserID"); }

			set { SetColumnValue("UserID", value); }

		}

		  
		[XmlAttribute("Username")]
		public string Username 
		{
			get { return GetColumnValue<string>("Username"); }

			set { SetColumnValue("Username", value); }

		}

		  
		[XmlAttribute("Email")]
		public string Email 
		{
			get { return GetColumnValue<string>("Email"); }

			set { SetColumnValue("Email", value); }

		}

		  
		[XmlAttribute("Comment")]
		public string Comment 
		{
			get { return GetColumnValue<string>("Comment"); }

			set { SetColumnValue("Comment", value); }

		}

		  
		[XmlAttribute("Password")]
		public string Password 
		{
			get { return GetColumnValue<string>("Password"); }

			set { SetColumnValue("Password", value); }

		}

		  
		[XmlAttribute("PasswordQuestion")]
		public string PasswordQuestion 
		{
			get { return GetColumnValue<string>("PasswordQuestion"); }

			set { SetColumnValue("PasswordQuestion", value); }

		}

		  
		[XmlAttribute("PasswordAnswer")]
		public string PasswordAnswer 
		{
			get { return GetColumnValue<string>("PasswordAnswer"); }

			set { SetColumnValue("PasswordAnswer", value); }

		}

		  
		[XmlAttribute("IsApproved")]
		public bool? IsApproved 
		{
			get { return GetColumnValue<bool?>("IsApproved"); }

			set { SetColumnValue("IsApproved", value); }

		}

		  
		[XmlAttribute("LastActivityDate")]
		public DateTime? LastActivityDate 
		{
			get { return GetColumnValue<DateTime?>("LastActivityDate"); }

			set { SetColumnValue("LastActivityDate", value); }

		}

		  
		[XmlAttribute("LastLoginDate")]
		public DateTime? LastLoginDate 
		{
			get { return GetColumnValue<DateTime?>("LastLoginDate"); }

			set { SetColumnValue("LastLoginDate", value); }

		}

		  
		[XmlAttribute("LastPasswordChangedDate")]
		public DateTime? LastPasswordChangedDate 
		{
			get { return GetColumnValue<DateTime?>("LastPasswordChangedDate"); }

			set { SetColumnValue("LastPasswordChangedDate", value); }

		}

		  
		[XmlAttribute("CreationDate")]
		public DateTime? CreationDate 
		{
			get { return GetColumnValue<DateTime?>("CreationDate"); }

			set { SetColumnValue("CreationDate", value); }

		}

		  
		[XmlAttribute("IsOnline")]
		public bool? IsOnline 
		{
			get { return GetColumnValue<bool?>("IsOnline"); }

			set { SetColumnValue("IsOnline", value); }

		}

		  
		[XmlAttribute("IsLockedOut")]
		public bool? IsLockedOut 
		{
			get { return GetColumnValue<bool?>("IsLockedOut"); }

			set { SetColumnValue("IsLockedOut", value); }

		}

		  
		[XmlAttribute("LastLockedOutDate")]
		public DateTime? LastLockedOutDate 
		{
			get { return GetColumnValue<DateTime?>("LastLockedOutDate"); }

			set { SetColumnValue("LastLockedOutDate", value); }

		}

		  
		[XmlAttribute("FailedPasswordAttemptCount")]
		public int? FailedPasswordAttemptCount 
		{
			get { return GetColumnValue<int?>("FailedPasswordAttemptCount"); }

			set { SetColumnValue("FailedPasswordAttemptCount", value); }

		}

		  
		[XmlAttribute("FailedPasswordAttemptWindowStart")]
		public DateTime? FailedPasswordAttemptWindowStart 
		{
			get { return GetColumnValue<DateTime?>("FailedPasswordAttemptWindowStart"); }

			set { SetColumnValue("FailedPasswordAttemptWindowStart", value); }

		}

		  
		[XmlAttribute("FailedPasswordAnswerAttemptCount")]
		public int? FailedPasswordAnswerAttemptCount 
		{
			get { return GetColumnValue<int?>("FailedPasswordAnswerAttemptCount"); }

			set { SetColumnValue("FailedPasswordAnswerAttemptCount", value); }

		}

		  
		[XmlAttribute("FailedPasswordAnswerAttemptWindowStart")]
		public DateTime? FailedPasswordAnswerAttemptWindowStart 
		{
			get { return GetColumnValue<DateTime?>("FailedPasswordAnswerAttemptWindowStart"); }

			set { SetColumnValue("FailedPasswordAnswerAttemptWindowStart", value); }

		}

		  
		[XmlAttribute("CreatedOn")]
		public DateTime? CreatedOn 
		{
			get { return GetColumnValue<DateTime?>("CreatedOn"); }

			set { SetColumnValue("CreatedOn", value); }

		}

		  
		[XmlAttribute("CreatedBy")]
		public string CreatedBy 
		{
			get { return GetColumnValue<string>("CreatedBy"); }

			set { SetColumnValue("CreatedBy", value); }

		}

		  
		[XmlAttribute("ModifiedOn")]
		public DateTime? ModifiedOn 
		{
			get { return GetColumnValue<DateTime?>("ModifiedOn"); }

			set { SetColumnValue("ModifiedOn", value); }

		}

		  
		[XmlAttribute("ModifiedBy")]
		public string ModifiedBy 
		{
			get { return GetColumnValue<string>("ModifiedBy"); }

			set { SetColumnValue("ModifiedBy", value); }

		}

		  
		[XmlAttribute("IsDeleted")]
		public bool IsDeleted 
		{
			get { return GetColumnValue<bool>("IsDeleted"); }

			set { SetColumnValue("IsDeleted", value); }

		}

		
		#endregion
		
		
		#region PrimaryKey Methods
		
		public LMSData.UserGroupMapCollection UserGroupMapRecords()
		{
			return new LMSData.UserGroupMapCollection().Where(UserGroupMap.Columns.UserID, UserID).Load();
		}

		public LMSData.UserCourseMapCollection UserCourseMapRecords()
		{
			return new LMSData.UserCourseMapCollection().Where(UserCourseMap.Columns.UserID, UserID).Load();
		}

		public LMSData.UserRoleMapCollection UserRoleMapRecords()
		{
			return new LMSData.UserRoleMapCollection().Where(UserRoleMap.Columns.UserID, UserID).Load();
		}

		public LMSData.UserProfileCollection UserProfileRecords()
		{
			return new LMSData.UserProfileCollection().Where(UserProfile.Columns.UserID, UserID).Load();
		}

		public LMSData.UserAssessmentCollection UserAssessmentRecords()
		{
			return new LMSData.UserAssessmentCollection().Where(UserAssessment.Columns.UserID, UserID).Load();
		}

		public LMSData.MessageCollection MessageRecords()
		{
			return new LMSData.MessageCollection().Where(Message.Columns.UserID, UserID).Load();
		}

		public LMSData.ThreadCollection ThreadRecords()
		{
			return new LMSData.ThreadCollection().Where(Thread.Columns.UserID, UserID).Load();
		}

		public LMSData.TrackingCollection TrackingRecords()
		{
			return new LMSData.TrackingCollection().Where(Tracking.Columns.UserID, UserID).Load();
		}

		public LMSData.AuditLaunchCollection AuditLaunchRecords()
		{
			return new LMSData.AuditLaunchCollection().Where(AuditLaunch.Columns.UserID, UserID).Load();
		}

		#endregion
		
			
		
		//no foreign key tables defined (0)
		
		
		
		#region Many To Many Helpers
		
		 
		public LMSData.RoleCollection GetRoleCollection() { return User.GetRoleCollection(this.UserID); }

		public static LMSData.RoleCollection GetRoleCollection(int varUserID)
		{
			SubSonic.QueryCommand cmd = new SubSonic.QueryCommand(
				"SELECT * FROM Role INNER JOIN UserRoleMap ON "+
				"Role.RoleID=UserRoleMap.RoleID WHERE UserRoleMap.UserID=@UserID", User.Schema.Provider.Name);
			
			cmd.AddParameter("@UserID", varUserID, DbType.Int32);
			IDataReader rdr = SubSonic.DataService.GetReader(cmd);
			RoleCollection coll = new RoleCollection();
			coll.LoadAndCloseReader(rdr);
			return coll;
		}

		
		public static void SaveRoleMap(int varUserID, RoleCollection items)
		{
			QueryCommandCollection coll = new SubSonic.QueryCommandCollection();
			//delete out the existing
			QueryCommand cmdDel = new QueryCommand("DELETE FROM UserRoleMap WHERE UserID=@UserID", User.Schema.Provider.Name);
			cmdDel.AddParameter("@UserID", varUserID);
			coll.Add(cmdDel);
			DataService.ExecuteTransaction(coll);
			foreach (Role item in items)
			{
				UserRoleMap varUserRoleMap = new UserRoleMap();
				varUserRoleMap.SetColumnValue("UserID", varUserID);
				varUserRoleMap.SetColumnValue("RoleID", item.GetPrimaryKeyValue());
				varUserRoleMap.Save();
			}

		}

		public static void SaveRoleMap(int varUserID, System.Web.UI.WebControls.ListItemCollection itemList) 
		{
			QueryCommandCollection coll = new SubSonic.QueryCommandCollection();
			//delete out the existing
			 QueryCommand cmdDel = new QueryCommand("DELETE FROM UserRoleMap WHERE UserID=@UserID", User.Schema.Provider.Name);
			cmdDel.AddParameter("@UserID", varUserID);
			coll.Add(cmdDel);
			DataService.ExecuteTransaction(coll);
			foreach (System.Web.UI.WebControls.ListItem l in itemList) 
			{
				if (l.Selected) 
				{
					UserRoleMap varUserRoleMap = new UserRoleMap();
					varUserRoleMap.SetColumnValue("UserID", varUserID);
					varUserRoleMap.SetColumnValue("RoleID", l.Value);
					varUserRoleMap.Save();
				}

			}

		}

		public static void SaveRoleMap(int varUserID , int[] itemList) 
		{
			QueryCommandCollection coll = new SubSonic.QueryCommandCollection();
			//delete out the existing
			 QueryCommand cmdDel = new QueryCommand("DELETE FROM UserRoleMap WHERE UserID=@UserID", User.Schema.Provider.Name);
			cmdDel.AddParameter("@UserID", varUserID);
			coll.Add(cmdDel);
			DataService.ExecuteTransaction(coll);
			foreach (int item in itemList) 
			{
				UserRoleMap varUserRoleMap = new UserRoleMap();
				varUserRoleMap.SetColumnValue("UserID", varUserID);
				varUserRoleMap.SetColumnValue("RoleID", item);
				varUserRoleMap.Save();
			}

		}

		
		public static void DeleteRoleMap(int varUserID) 
		{
			QueryCommand cmdDel = new QueryCommand("DELETE FROM UserRoleMap WHERE UserID=@UserID", User.Schema.Provider.Name);
			cmdDel.AddParameter("@UserID", varUserID);
			DataService.ExecuteQuery(cmdDel);
		}

		
		 
		public LMSData.GroupCollection GetGroupCollection() { return User.GetGroupCollection(this.UserID); }

		public static LMSData.GroupCollection GetGroupCollection(int varUserID)
		{
			SubSonic.QueryCommand cmd = new SubSonic.QueryCommand(
				"SELECT * FROM [Group] INNER JOIN UserGroupMap ON "+
				"[Group].GroupID=UserGroupMap.GroupID WHERE UserGroupMap.UserID=@UserID", User.Schema.Provider.Name);
			
			cmd.AddParameter("@UserID", varUserID, DbType.Int32);
			IDataReader rdr = SubSonic.DataService.GetReader(cmd);
			GroupCollection coll = new GroupCollection();
			coll.LoadAndCloseReader(rdr);
			return coll;
		}

		
		public static void SaveGroupMap(int varUserID, GroupCollection items)
		{
			QueryCommandCollection coll = new SubSonic.QueryCommandCollection();
			//delete out the existing
			QueryCommand cmdDel = new QueryCommand("DELETE FROM UserGroupMap WHERE UserID=@UserID", User.Schema.Provider.Name);
			cmdDel.AddParameter("@UserID", varUserID);
			coll.Add(cmdDel);
			DataService.ExecuteTransaction(coll);
			foreach (Group item in items)
			{
				UserGroupMap varUserGroupMap = new UserGroupMap();
				varUserGroupMap.SetColumnValue("UserID", varUserID);
				varUserGroupMap.SetColumnValue("GroupID", item.GetPrimaryKeyValue());
				varUserGroupMap.Save();
			}

		}

		public static void SaveGroupMap(int varUserID, System.Web.UI.WebControls.ListItemCollection itemList) 
		{
			QueryCommandCollection coll = new SubSonic.QueryCommandCollection();
			//delete out the existing
			 QueryCommand cmdDel = new QueryCommand("DELETE FROM UserGroupMap WHERE UserID=@UserID", User.Schema.Provider.Name);
			cmdDel.AddParameter("@UserID", varUserID);
			coll.Add(cmdDel);
			DataService.ExecuteTransaction(coll);
			foreach (System.Web.UI.WebControls.ListItem l in itemList) 
			{
				if (l.Selected) 
				{
					UserGroupMap varUserGroupMap = new UserGroupMap();
					varUserGroupMap.SetColumnValue("UserID", varUserID);
					varUserGroupMap.SetColumnValue("GroupID", l.Value);
					varUserGroupMap.Save();
				}

			}

		}

		public static void SaveGroupMap(int varUserID , int[] itemList) 
		{
			QueryCommandCollection coll = new SubSonic.QueryCommandCollection();
			//delete out the existing
			 QueryCommand cmdDel = new QueryCommand("DELETE FROM UserGroupMap WHERE UserID=@UserID", User.Schema.Provider.Name);
			cmdDel.AddParameter("@UserID", varUserID);
			coll.Add(cmdDel);
			DataService.ExecuteTransaction(coll);
			foreach (int item in itemList) 
			{
				UserGroupMap varUserGroupMap = new UserGroupMap();
				varUserGroupMap.SetColumnValue("UserID", varUserID);
				varUserGroupMap.SetColumnValue("GroupID", item);
				varUserGroupMap.Save();
			}

		}

		
		public static void DeleteGroupMap(int varUserID) 
		{
			QueryCommand cmdDel = new QueryCommand("DELETE FROM UserGroupMap WHERE UserID=@UserID", User.Schema.Provider.Name);
			cmdDel.AddParameter("@UserID", varUserID);
			DataService.ExecuteQuery(cmdDel);
		}

		
		 
		public LMSData.CourseCollection GetCourseCollection() { return User.GetCourseCollection(this.UserID); }

		public static LMSData.CourseCollection GetCourseCollection(int varUserID)
		{
			SubSonic.QueryCommand cmd = new SubSonic.QueryCommand(
				"SELECT * FROM Course INNER JOIN UserCourseMap ON "+
				"Course.CourseID=UserCourseMap.CourseID WHERE UserCourseMap.UserID=@UserID AND Course.IsDeleted = 'false'", User.Schema.Provider.Name);
			
			cmd.AddParameter("@UserID", varUserID, DbType.Int32);
			IDataReader rdr = SubSonic.DataService.GetReader(cmd);
			CourseCollection coll = new CourseCollection();
			coll.LoadAndCloseReader(rdr);
			return coll;
		}

		
		public static void SaveCourseMap(int varUserID, CourseCollection items)
		{
			QueryCommandCollection coll = new SubSonic.QueryCommandCollection();
			//delete out the existing
			QueryCommand cmdDel = new QueryCommand("DELETE FROM UserCourseMap WHERE UserID=@UserID", User.Schema.Provider.Name);
			cmdDel.AddParameter("@UserID", varUserID);
			coll.Add(cmdDel);
			DataService.ExecuteTransaction(coll);
			foreach (Course item in items)
			{
				UserCourseMap varUserCourseMap = new UserCourseMap();
				varUserCourseMap.SetColumnValue("UserID", varUserID);
				varUserCourseMap.SetColumnValue("CourseID", item.GetPrimaryKeyValue());
				varUserCourseMap.Save();
			}

		}

		public static void SaveCourseMap(int varUserID, System.Web.UI.WebControls.ListItemCollection itemList) 
		{
			QueryCommandCollection coll = new SubSonic.QueryCommandCollection();
			//delete out the existing
			 QueryCommand cmdDel = new QueryCommand("DELETE FROM UserCourseMap WHERE UserID=@UserID", User.Schema.Provider.Name);
			cmdDel.AddParameter("@UserID", varUserID);
			coll.Add(cmdDel);
			DataService.ExecuteTransaction(coll);
			foreach (System.Web.UI.WebControls.ListItem l in itemList) 
			{
				if (l.Selected) 
				{
					UserCourseMap varUserCourseMap = new UserCourseMap();
					varUserCourseMap.SetColumnValue("UserID", varUserID);
					varUserCourseMap.SetColumnValue("CourseID", l.Value);
					varUserCourseMap.Save();
				}

			}

		}

		public static void SaveCourseMap(int varUserID , int[] itemList) 
		{
			QueryCommandCollection coll = new SubSonic.QueryCommandCollection();
			//delete out the existing
			 QueryCommand cmdDel = new QueryCommand("DELETE FROM UserCourseMap WHERE UserID=@UserID", User.Schema.Provider.Name);
			cmdDel.AddParameter("@UserID", varUserID);
			coll.Add(cmdDel);
			DataService.ExecuteTransaction(coll);
			foreach (int item in itemList) 
			{
				UserCourseMap varUserCourseMap = new UserCourseMap();
				varUserCourseMap.SetColumnValue("UserID", varUserID);
				varUserCourseMap.SetColumnValue("CourseID", item);
				varUserCourseMap.Save();
			}

		}

		
		public static void DeleteCourseMap(int varUserID) 
		{
			QueryCommand cmdDel = new QueryCommand("DELETE FROM UserCourseMap WHERE UserID=@UserID", User.Schema.Provider.Name);
			cmdDel.AddParameter("@UserID", varUserID);
			DataService.ExecuteQuery(cmdDel);
		}

		
		#endregion
		
		#region ObjectDataSource support
		
		
		/// <summary>
		/// Inserts a record, can be used with the Object Data Source
		/// </summary>
		public static void Insert(string varUsername,string varEmail,string varComment,string varPassword,string varPasswordQuestion,string varPasswordAnswer,bool? varIsApproved,DateTime? varLastActivityDate,DateTime? varLastLoginDate,DateTime? varLastPasswordChangedDate,DateTime? varCreationDate,bool? varIsOnline,bool? varIsLockedOut,DateTime? varLastLockedOutDate,int? varFailedPasswordAttemptCount,DateTime? varFailedPasswordAttemptWindowStart,int? varFailedPasswordAnswerAttemptCount,DateTime? varFailedPasswordAnswerAttemptWindowStart,DateTime? varCreatedOn,string varCreatedBy,DateTime? varModifiedOn,string varModifiedBy,bool varIsDeleted)
		{
			User item = new User();
			
			item.Username = varUsername;
			
			item.Email = varEmail;
			
			item.Comment = varComment;
			
			item.Password = varPassword;
			
			item.PasswordQuestion = varPasswordQuestion;
			
			item.PasswordAnswer = varPasswordAnswer;
			
			item.IsApproved = varIsApproved;
			
			item.LastActivityDate = varLastActivityDate;
			
			item.LastLoginDate = varLastLoginDate;
			
			item.LastPasswordChangedDate = varLastPasswordChangedDate;
			
			item.CreationDate = varCreationDate;
			
			item.IsOnline = varIsOnline;
			
			item.IsLockedOut = varIsLockedOut;
			
			item.LastLockedOutDate = varLastLockedOutDate;
			
			item.FailedPasswordAttemptCount = varFailedPasswordAttemptCount;
			
			item.FailedPasswordAttemptWindowStart = varFailedPasswordAttemptWindowStart;
			
			item.FailedPasswordAnswerAttemptCount = varFailedPasswordAnswerAttemptCount;
			
			item.FailedPasswordAnswerAttemptWindowStart = varFailedPasswordAnswerAttemptWindowStart;
			
			item.CreatedOn = varCreatedOn;
			
			item.CreatedBy = varCreatedBy;
			
			item.ModifiedOn = varModifiedOn;
			
			item.ModifiedBy = varModifiedBy;
			
			item.IsDeleted = varIsDeleted;
			
		
			if (System.Web.HttpContext.Current != null)
				item.Save(System.Web.HttpContext.Current.User.Identity.Name);
			else
				item.Save(System.Threading.Thread.CurrentPrincipal.Identity.Name);
		}

		
		/// <summary>
		/// Updates a record, can be used with the Object Data Source
		/// </summary>
		public static void Update(int varUserID,string varUsername,string varEmail,string varComment,string varPassword,string varPasswordQuestion,string varPasswordAnswer,bool? varIsApproved,DateTime? varLastActivityDate,DateTime? varLastLoginDate,DateTime? varLastPasswordChangedDate,DateTime? varCreationDate,bool? varIsOnline,bool? varIsLockedOut,DateTime? varLastLockedOutDate,int? varFailedPasswordAttemptCount,DateTime? varFailedPasswordAttemptWindowStart,int? varFailedPasswordAnswerAttemptCount,DateTime? varFailedPasswordAnswerAttemptWindowStart,DateTime? varCreatedOn,string varCreatedBy,DateTime? varModifiedOn,string varModifiedBy,bool varIsDeleted)
		{
			User item = new User();
			
				item.UserID = varUserID;
				
				item.Username = varUsername;
				
				item.Email = varEmail;
				
				item.Comment = varComment;
				
				item.Password = varPassword;
				
				item.PasswordQuestion = varPasswordQuestion;
				
				item.PasswordAnswer = varPasswordAnswer;
				
				item.IsApproved = varIsApproved;
				
				item.LastActivityDate = varLastActivityDate;
				
				item.LastLoginDate = varLastLoginDate;
				
				item.LastPasswordChangedDate = varLastPasswordChangedDate;
				
				item.CreationDate = varCreationDate;
				
				item.IsOnline = varIsOnline;
				
				item.IsLockedOut = varIsLockedOut;
				
				item.LastLockedOutDate = varLastLockedOutDate;
				
				item.FailedPasswordAttemptCount = varFailedPasswordAttemptCount;
				
				item.FailedPasswordAttemptWindowStart = varFailedPasswordAttemptWindowStart;
				
				item.FailedPasswordAnswerAttemptCount = varFailedPasswordAnswerAttemptCount;
				
				item.FailedPasswordAnswerAttemptWindowStart = varFailedPasswordAnswerAttemptWindowStart;
				
				item.CreatedOn = varCreatedOn;
				
				item.CreatedBy = varCreatedBy;
				
				item.ModifiedOn = varModifiedOn;
				
				item.ModifiedBy = varModifiedBy;
				
				item.IsDeleted = varIsDeleted;
				
			item.IsNew = false;
			if (System.Web.HttpContext.Current != null)
				item.Save(System.Web.HttpContext.Current.User.Identity.Name);
			else
				item.Save(System.Threading.Thread.CurrentPrincipal.Identity.Name);
		}

		#endregion
		#region Columns Struct
		public struct Columns
		{
			 public static string UserID = @"UserID";
			 public static string Username = @"Username";
			 public static string Email = @"Email";
			 public static string Comment = @"Comment";
			 public static string Password = @"Password";
			 public static string PasswordQuestion = @"PasswordQuestion";
			 public static string PasswordAnswer = @"PasswordAnswer";
			 public static string IsApproved = @"IsApproved";
			 public static string LastActivityDate = @"LastActivityDate";
			 public static string LastLoginDate = @"LastLoginDate";
			 public static string LastPasswordChangedDate = @"LastPasswordChangedDate";
			 public static string CreationDate = @"CreationDate";
			 public static string IsOnline = @"IsOnline";
			 public static string IsLockedOut = @"IsLockedOut";
			 public static string LastLockedOutDate = @"LastLockedOutDate";
			 public static string FailedPasswordAttemptCount = @"FailedPasswordAttemptCount";
			 public static string FailedPasswordAttemptWindowStart = @"FailedPasswordAttemptWindowStart";
			 public static string FailedPasswordAnswerAttemptCount = @"FailedPasswordAnswerAttemptCount";
			 public static string FailedPasswordAnswerAttemptWindowStart = @"FailedPasswordAnswerAttemptWindowStart";
			 public static string CreatedOn = @"CreatedOn";
			 public static string CreatedBy = @"CreatedBy";
			 public static string ModifiedOn = @"ModifiedOn";
			 public static string ModifiedBy = @"ModifiedBy";
			 public static string IsDeleted = @"IsDeleted";
						
		}

		#endregion
	}

}

